<template>
	<view class="diy-page">
		<diy :diyItems="items"></diy>
		<mainfooter
		  ref="footer-bar"
		  @click="cut_index"
		  :bottom="detectionModel() ? 20 : 0"
		></mainfooter>
	</view>
</template>

<script>
  import forums from '@/mixin/forums';
  import user from '@/mixin/user';
  import { mapState, mapMutations } from 'vuex';
  import detectionModel from '@/mixin/detectionModel';
  import loginModule from '@/mixin/loginModule';
  import { throttle } from 'lodash';
  import mainfooter from '../components/footer/footer'
  import diy from '@/components/diy/diy.vue';
  import newApi from '../../api/new-api';

	export default {
		components: {
			diy,
      mainfooter
		},
     mixins: [forums, user, detectionModel, loginModule],
		data() {
			return {
				/*页面ID*/
				page_id:null,
				/*diy类别*/
				items:{},
				/*页面信息*/
				page_info:{}
			}
		},
		onLoad(e) {
			this.page_id=e.page_id;
			this.getData();
		},
		methods: {
			/*获取数据*/
			getData(page_id) {
				let self = this;
				self._get('index/index', {
					page_id: self.page_id
				}, function(res) {
					self.page_info = res.data.page;
					self.items = res.data.items;
					self.setPage(self.page_info);

				});
			},

			/*设置页面*/
			setPage(page){

				uni.setNavigationBarTitle({
				    title: page.params.title
				});

				let colors='#000000';
				if(page.style.titleTextColor=='white'){
					//字母要小写
					colors='#ffffff'
				}
				uni.setNavigationBarColor({
				    frontColor: colors,
				    backgroundColor: page.style.titleBackgroundColor
				})

			},
      // 切换组件
      cut_index(e, type, isTabBar) {
        if(type==1||type==2){
          //圈子
           this.setFooterIndex(1);
        }else
        {
          this.setFooterIndex(type);
        }
        console.log(e.url)
        uni.navigateTo({
             url: e.url,
                        })
      },
		},

	}
</script>

<style>

</style>
